-
-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add OneKey keyring #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
2dc83be to
a18c779
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
2 similar comments
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
ca02a28 to
89518ee
Compare
|
@SocketSecurity ignore npm/async-function |
89518ee to
ca5bb42
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
| reject(new Error('signature doesnt match the right address')); | ||
| } | ||
| // eslint-disable-next-line promise/no-multiple-resolved | ||
| resolve(signature); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing return after reject causes double promise resolution
Medium Severity
In signPersonalMessage, when the recovered signature address doesn't match the expected account, reject() is called but execution continues and resolve(signature) is also invoked. The eslint-disable-next-line promise/no-multiple-resolved comment confirms this was caught by the linter but suppressed rather than fixed. While Promise semantics mean the rejection wins, calling both reject and resolve on the same promise is incorrect behavior and could lead to confusion or bugs if the code is modified later. A return statement is needed after the reject() call.
| #onUIEvent?: ((event: Unsuccessful['payload']) => void) | undefined; | ||
|
|
||
| #handleBlockErrorEvent(payload: Unsuccessful): void { | ||
| const { code } = payload.payload; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing null check causes crash in error handler
Medium Severity
The #handleBlockErrorEvent method immediately destructures payload.payload without a null check, but callers pass result after checking result?.success with optional chaining. This inconsistency means if an SDK method returns null or undefined, the optional chaining check passes (since undefined?.success is falsy), but then #handleBlockErrorEvent(result) crashes with a TypeError when accessing undefined.payload. The pattern repeats in getPublicKey, getPassphraseState, ethereumSignTransaction, ethereumSignMessage, and ethereumSignTypedData.
Additional Locations (2)
|
@SocketSecurity ignore npm/async-function@1.0.0 |
| reject(new Error('signature doesnt match the right address')); | ||
| } | ||
| // eslint-disable-next-line promise/no-multiple-resolved | ||
| resolve(signature); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing return after reject causes multiple promise settlements
Medium Severity
In signPersonalMessage, when the recovered address doesn't match the expected address, reject() is called but execution continues and resolve(signature) is also called. The eslint-disable comment for promise/no-multiple-resolved acknowledges this issue but masks it rather than fixing it. A return statement is needed after the reject() call to prevent the promise from being settled twice and to avoid returning an invalid signature path.
| }, | ||
| }); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UI_EVENT subscription never removed causes memory leak
Medium Severity
The UI_EVENT event listener added via this.sdk?.on('UI_EVENT', ...) in init() is never unsubscribed. Neither destroy() nor dispose() removes this listener before clearing the SDK reference. The callback closure holds references to this (the bridge instance), causing memory to accumulate if the bridge is initialized and destroyed multiple times during the application lifecycle.
Additional Locations (1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| async dispose(): Promise<void> { | ||
| this.sdk?.dispose(); | ||
| return Promise.resolve(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dispose() doesn't reset state preventing SDK re-initialization
Medium Severity
The dispose() method calls sdk.dispose() but doesn't reset isSDKInitialized or sdk. Since OneKeyKeyring.destroy() calls bridge.dispose() (not bridge.destroy()), the bridge is left in an inconsistent state where isSDKInitialized remains true but the SDK is disposed. Subsequent calls to init() return early without re-initializing, and SDK method calls will fail on the disposed SDK.
Additional Locations (1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
e40d1ad to
15bb912
Compare
15bb912 to
acd41b7
Compare
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
1 similar comment
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
|
|
||
| return this.hdPath === newHdPath; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing lock() method causes test runtime failure
High Severity
The OneKeyKeyring class is missing a lock() method, but the test file explicitly calls keyring.lock() and expects isUnlocked() to return false afterward. Since isUnlocked() returns Boolean(this.hdk?.publicKey), a lock() method that resets the HDKey is needed for the feature to work and for the test to pass. Without this method, the test will fail with a runtime error and the keyring cannot be locked programmatically.
Additional Locations (1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
feb98c5 to
2d9d5c0
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
Adds OneKey keyring based on OneKey libraries.
Note
Adds OneKey hardware wallet support to the monorepo via a new keyring package.
@metamask/eth-onekey-keyringpackage withOneKeyKeyringandOneKeyWebBridgeusing@onekeyfe/hd-web-sdkto handle PIN/passphrase UI, passphrase state, and transport switchingWritten by Cursor Bugbot for commit 2d9d5c0. This will update automatically on new commits. Configure here.